package com.et.util.listener;

import java.util.Map;

import unis.base.util.ValidateUtil;

import com.et.pojo.CustomerInfo;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * 是否登录拦截器设置
 * 
 * @author Administrator
 */
public class AuthenticationInteceptor implements Interceptor {
	private int customerType;
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		String result = "unLogin";
		Map<String, Object> session = ActionContext.getContext().getSession();
		CustomerInfo customerInfo = (CustomerInfo) session.get("customerInfo");
		if(ValidateUtil.isNotNull(customerInfo)){
			if (customerInfo.getCustomerType() == customerType) {
				return actionInvocation.invoke();
			}
		}
		return result;
	}

	public void destroy() {
		// TODO Auto-generated method stub
		
	}

	public void init() {
		// TODO Auto-generated method stub
		
	}

	public int getCustomerType() {
		return customerType;
	}

	public void setCustomerType(int customerType) {
		this.customerType = customerType;
	}
	
	
	

}
